package com.codedancer.campus.mapper;

import cn.hutool.core.collection.CollectionUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.codedancer.campus.common.core.BaseMapper;
import com.codedancer.campus.po.CommodityExamineRecord;
import com.codedancer.campus.po.ConfessionalWallExamineRecord;
import com.codedancer.campus.qo.commodity.CommodityExamineRecordPageSearchQo;
import com.codedancer.campus.qo.confessionalWall.ConfessionalWallExamineRecordPageSearchQo;
import org.apache.ibatis.annotations.Param;

public interface ConfessionalWallExamineRecordMapper extends BaseMapper<ConfessionalWallExamineRecord> {

    /**
     * 分页查询表白墙审核记录
     *
     * @param confessionalWallExamineRecordPage
     * @param confessionalWallExamineRecordPageSearchQo
     * @return
     */
    IPage<ConfessionalWallExamineRecord> page(Page<ConfessionalWallExamineRecord> confessionalWallExamineRecordPage,
                                              @Param("confessionalWallExamineRecordPageSearchQo") ConfessionalWallExamineRecordPageSearchQo confessionalWallExamineRecordPageSearchQo);

    /**
     * 查询最近一条表白墙记录
     *
     * @param uuid
     * @return
     */
    default ConfessionalWallExamineRecord selectLastExamineRecord(String uuid) {
        LambdaQueryWrapper<ConfessionalWallExamineRecord> lambdaQueryWrapper = new LambdaQueryWrapper<>();
        lambdaQueryWrapper.eq(ConfessionalWallExamineRecord::getConfessionalWallUuid, uuid);
        lambdaQueryWrapper.orderByDesc(ConfessionalWallExamineRecord::getCreateTime);
        return CollectionUtil.isNotEmpty(selectList(lambdaQueryWrapper)) ? selectList(
            lambdaQueryWrapper).get(0) : null;
    }
}
